﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace katOS
{
    class FileInUse
    {
        int handler;
        string name;
        static List<int> process_use;
        public volatile static List<String> fileContent;

        public void setName(string filename)
        {
            name = filename;
        }

        public string getName()
        {
            return name;
        }

        public void setHandler(int a_handler)
        {
            handler = a_handler;
        }

        public int getHandler()
        {
            return handler;
        }

        public FileInUse()
        {
            process_use = new List<int>();
            fileContent = new List<string>();
        }

        public void AddProcess(int pid)
        {
            process_use.Add(pid);
        }

        public void RemoveProcess(int pid)
        {
            process_use.Remove(pid);
        }

        public List<int> getProcessesList()
        {
            return process_use;
        }

        public void setFileContent(string filename)
        {
            StreamReader reader = new StreamReader("C:/Users/kareAndy/Documents/UVG/Ciclo 5/CC3002 Sistemas Operativos/Proyecto No. 1/katOSFiles/" + filename);

            string a_line = reader.ReadLine();

            while (a_line != null)
            {
                fileContent.Add(a_line);
                a_line = reader.ReadLine();
            }
        }

        public List<String> getFileContent()
        {
            return fileContent;
        }
    }
}
